#include "Edge.h"

Edge::Edge(Vertex* start,Vertex* end,QObject* parent):
    QObject(parent),
    QGraphicsLineItem(start->point.x(),start->point.y(),end->point.x(),end->point.y()),
    start(start),
    end(end)
{
}

void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    QLineF line(start->point,end->point);
    QPen pen(QColor(125,185,222));
    pen.setWidth(2);
    painter->setPen(pen);
    painter->setRenderHint(QPainter::HighQualityAntialiasing);
    painter->drawLine(line);
    painter->setFont(TagFont);
    painter->setPen(Qt::black);
    painter->drawText(QPointF((start->point.x()+end->point.x())/2,(start->point.y()+end->point.y())/2),QString::number(Z));
}
